<template>
    <div>
        <form style="margin-top:50px;" @submit.prevent="sub">
            <label for="name">
                用户名：
            </label>
            <input v-model="username.name" type="text"> 
            <label for="pass"> 密码：</label>
            <input v-model="username.pass" type="password">
            <input type="submit" value="登录">
        </form>
    </div>
</template>
<script>
export default {
    data() {
        return {
            username:{
                name:'',
                pass:'',
            }
        }     
    },
    methods:{
        sub(){
            localStorage.setItem('name',this.username.name);
            this.$router.push('/');
            window.location.reload()
        }
    }
}
</script>